//
//  SelecSeatSubmitView.swift
//  AirlineReservation
//
//  Created by Kevin on 2020/2/13.
//  Copyright © 2020 Kevin. All rights reserved.
//

import UIKit

class SelecSeatSubmitView: UIView {

   // 选中条数
    private let label = UILabel(title: "请选择座位", color: COLOR_NICE, size: 13)
    // 确认按钮
    private let okLabel = UILabel(title: "确认座位", color: UIColor.black,align: .center)
    
    // 修改选中的座位号
    public var modifyShowSeat:String? {
        didSet {
            label.text = modifyShowSeat
            okLabel.isUserInteractionEnabled = true
        }
    }
    
    // 修改确认按钮文本
    public var modifyShowSeatBtn:String? {
        didSet {
            label.text = modifyShowSeatBtn
            okLabel.isUserInteractionEnabled = false
        }
    }
    
    // 回调
    public var complete:(() -> Void)?
    
    override func layoutSubviews() {
        // 选中条数
        label.frame = CGRect(x: MARGIN20, y: 0, width: frame.width * 0.65, height: frame.height)
        addSubview(label)
        // 确认退票按钮
        okLabel.font = UIFont.systemFont(ofSize: 16)
        okLabel.textColor = UIColor.white
        okLabel.backgroundColor = COLOR_RED
        okLabel.isUserInteractionEnabled = false
        okLabel.frame = CGRect(x: label.frame.maxX - MARGIN20, y: 0, width: frame.width * 0.35, height: frame.height)
        addSubview(okLabel)
        // 确认退票按钮 添加点击事件
        okLabel.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(clickItem)))
    }
    
    @objc func clickItem() -> Void {
        if let callback = complete {
            callback()
        }
    }

}
